<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp"%>
<html>
<head>
<title>文件上传</title>
<!-- import css and js -->
<%@ include file="/common/meta.jsp"%>
<script src="${ctx}/js/ligerUI/js/plugins/ligerLayout.js"
	type="text/javascript"></script>
<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
<script src="${ctx}/js/complete/ajaxfileupload.js" type="text/javascript"></script>
<script type="text/javascript">
		var upload_Url="${ctx}/util/fileUplod";
		function getPath(){
			return $("#path").val();
		}
		
		function Close(){
			CloseDialog();
		}
		function uploadFile(){
			var f=$("#file").val();
			if(f==""||f==null){
				return;
			}
			    $.ajaxFileUpload  
			    ({  
			            url:upload_Url+".do",  
			            secureuri:false,  
			            fileElementId:'file',  
			            dataType: 'string',  
			            success: function (data, status)  
			            {  	//返回的不是预定格式
			            	data=data.replace("<pre>","").replace("</pre>","");
			                arr=data.split(",");
			             	if(arr[0]=="0"){
			                	$("#img").attr("src",arr[1]);
			                	$("#img").show();
			                	$("#path").val(arr[2]);
			                } 
			            },  
			            error: function (data, status, e)  
			            {  
			                alert(data.status);  
			                alert(data.message+" error:"+e);  
			            }  
			              
			        }  
			    ); 
			    return false;  
			  
		}
	</script>

</head>
<body style="padding: 10px">
	<div class="pageContent" align="center">
		
			<table class="TableBlock" align="center">
				<tr>
					<td>
						<input type="text" id="fileName"  readonly="readonly" style="width: 40%;"  value=""/>
   		                <input type="button" value="选择" onclick="$('#file').click()"/>
   		                <input type="button" value="上传" onclick="uploadFile();"/>
   		                <input type="hidden" id="path" name="path"/>
   		                <input type="file"  style="display:none;" id="file" name="file" onchange="$('#fileName').val($('#file').val());"/> 
					</td>
				</tr>
				<tr></tr><tr></tr><tr></tr>
				<tr>
					<td align="center">
						<img id="img" src="" style="display:none;"/>
					</td>
				</tr>
			</table>
			 <div class="clear"></div>
	</div>
</body>
</html>